<template>
  <div id="index">
    <dv-full-screen-container class="bg">
      <dv-loading v-if="loading">Loading...</dv-loading>
      <div v-else class="host-body">

        <div class="set-height">
          <div class="d-flex jc-center header-h">
            <dv-decoration-10 style="width:33.3%;height:.0625rem;" />
            <div class="d-flex jc-center">
              <dv-decoration-8 :color="['#568aea', '#000000']" style="width:2.5rem;height:.625rem;" />
              <div class="title">
                <span class="title-text" style="width: 100%;">广州豪鹏可视化运营平台</span>
                <dv-decoration-6
                  class="title-bototm"
                  :reverse="true"
                  :color="['#50e3c2', '#67a1e5']"
                  style="width:3.125rem;height:.1rem;"
                />
              </div>
              <dv-decoration-8
                :reverse="true"
                :color="['#568aea', '#000000']"
                style="width:2.5rem;height:.625rem;"
              />
            </div>
            <dv-decoration-10 style="width:33.3%;height:.0625rem; transform: rotateY(180deg);" />
            <!-- <div class="weather-s">
              <div class="weather-s-img"><img src="./img/weather.png" /></div>
              <span>当前天气<i>多云</i></span>
            </div> -->
          </div>

          <!-- 第二行 -->
          <div class="d-flex jc-between px-2 header-h">

            <div class="d-flex" style="width: 40%">

              <div @click="nodeClick('1')" class="react-right ml-4" style="position: relative; width: 6.25rem; text-align: left;background-color:#009ADF;">
                <span class="react-before"></span>
                <span class="react-before-img text">
                  <img src="./img/logo.png" />
                </span>
                <span :class="{ colorBlue: setColor === '1' }" class="text fw-b" style="text-align: center;width: 100%;">总览</span>
              </div>

              <div @click="nodeClick('2')" class="react-right ml-3" style="background-color: #009ADF;">
                <span :class="{ colorBlue: setColor === '2' }" class="text fw-b">智能工厂</span>
                <!-- <span :class="{ colorBlue: setColor === '2' }" class="text fw-b">行政管理</span> -->
              </div>

              <!-- <div @click="nodeClick('3')" class="react-right ml-3" style="background-color: #009ADF;">
                <span :class="{ colorBlue: setColor === '3' }" class="text fw-b">能源管理</span>
                <span :class="{ colorBlue: setColor === '3' }" class="text fw-b">安全管理</span>
              </div> -->
              
            </div>

            <div style="width: 40%" class="d-flex">

              <div @click="nodeClick('3')" class="react-left bg-color-blue mr-3" style="background-color: #009ADF;">
                <span :class="{ colorBlue: setColor === '3' }" class="text fw-b">能源管理</span>
              </div>

              <div @click="nodeClick('4')" class="react-left bg-color-blue mr-3" style="background-color: #009ADF;">
                <!-- <span :class="{ colorBlue: setColor === '4' }" class="text fw-b">能源管理</span> -->
                <span :class="{ colorBlue: setColor === '4' }" class="text fw-b">行政安全</span>
              </div>

              <!-- <div @click="nodeClick('5')" class="react-left bg-color-blue mr-3" style="background-color: rgba(15,48,98,1);">
                <span :class="{ colorBlue: setColor === '5' }" class="text fw-b">智能工厂</span>
              </div> -->

              <div class="react-left mr-4 set-p" style="width: 6.25rem; background-color: #009ADF; text-align: right;">
                <div class="weather-s text">
                  <div class="weather-s-img"><img src="./img/weather.png" /></div>
                  <span>当前天气<i>多云</i></span>
                </div>
                <span class="react-after"></span>
                <span class="text">{{currtime}}</span>
              </div>

            </div>
          </div>
        </div>

        <div class="body-box">
          <router-view></router-view>
        </div>
      </div>
    </dv-full-screen-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: true,
      currtime: "",
      setColor: '1',
      getHeight: '',
    };
  },
  components: {},
  mounted() {
    let that = this
    that.$nextTick(() => {
      that.cancelLoading();
      // 定时刷新当前时间
      that.currentTime();
    })
  },
  methods: {
    /*** nodeClick 菜单点击 */
    nodeClick(val){
      this.setColor = val;
      switch(val){
        case '1':
          // 总览
          this.$router.push( {path: '/'} );
          break;
        case '2':
          // 行政管理
          this.$router.push( {path: '/factoryMin'} ); // 智能工厂
          // this.$router.push( {path: '/administrationMin'} );
          break;
        case '3':
          // 安全管理
          this.$router.push( {path: '/energyMin'} ); // 能源管理
          // this.$router.push( {path: '/safetyMin'} );
          break;
        case '4':
          // 能源管理
          this.$router.push( {path: '/adminTwo'} ); // 行政安全
          // this.$router.push( {path: '/energyMin'} );
          break;
        case '5':
          // 智能工厂
          // this.$router.push( {path: '/factoryMin'} );
          break;
      }
    },

    getTime: function () {
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      _this.currtime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
    },
    currentTime() {
      setInterval(this.getTime, 500);
    },
    cancelLoading() {
      setTimeout(() => {
        this.loading = false;
      }, 500);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../assets/scss/index.scss";
::deep(#dv-full-screen-container){
  height: auto!important;
}
#index{
  .header-h{
    height: 40px;
  }
  .set-p{
    position: relative;
    .weather-s{
      position: absolute;
      left: 50px;
      // bottom: 8px;
      display: flex !important;
      flex-direction: row;
      align-items: center;
      .weather-s-img{
        width: 20px;
        height: 20px;
        margin-right: 8px;
        img{
          display: block;
          width: 100%;
        }
      }
      span{
        color: rgba($color: #FFFFFF, $alpha: 0.8);
        i{
          color: rgba($color: #FFB300, $alpha: 0.8);
          margin-left: 8px;
          font-style: normal;
        }
      }
    }
  }
  .set-height{
    height: 80px;
    margin-bottom: 10px;
  }
  .body-box{
    height: calc(100vh - 96px);
    padding: 0 0.1rem;
  }
  .react-before-img{
    height: 30px;
    position:fixed;
    left: 0px;
    // top: 50%;
    top: 6px;
    // margin-top: -15px;
    img{
      display: block;
      height: 100%;
    }
  }
}
</style>